package com.jxgc.file.oi;

import java.time.Year;
import java.util.Calendar;
import java.util.Date;

public class calendar {
    public static void main(String[] args) {
        //目标；掌握calendar的使用和特点、
        //1. 得到系统此刻时间对应的日历对象。
        Calendar now = Calendar.getInstance();
        System.out.println(now);  //日历内月份从0开始记录  所以月份要加1

        //获取日历中的某个信息
       int year = now.get(Calendar.YEAR); //不知道量是什么就可以先打印
        System.out.println(year);

        int month = now.get(Calendar.MONTH)+1;
        System.out.println(month);

        int week = now.get(Calendar.WEEK_OF_YEAR);
        System.out.println("第"+week+"周");


        //3.拿到日历中记录的日期对象
      Date d =  now.getTime();
        System.out.println(d);

        //4.拿到时间毫秒值
        long time  =   now.getTimeInMillis();
        System.out.println(time);
        System.out.println("-------------------------------");

        //5.修改日历中的某个信息
        now.set(Calendar.MONTH,9);  //修改月份变成10月    因为月份要加1
        now.set(Calendar.YEAR,2050);
        System.out.println(now);
        System.out.println("---------------------------------");

        //为某个信息增加或者减少多少
         now.add(Calendar.DAY_OF_MONTH,2);
         now.add(Calendar.DAY_OF_YEAR,20);
         now.add(Calendar.DAY_OF_WEEK,1);
        System.out.println(now);

    }
}





